<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%@ page import="com.conversationboard.model.*" %>
<%@ page import="com.conversationboard.view.*" %>
<%@ page import="com.conversationboard.config.*" %>
<%@ page import="java.util.List"%>
<%@ page import="com.conversationboard.cache.newanswers.NewAnswersThread"%>
<%@ page import="com.conversationboard.site.Site"%>
<%@ page import="java.security.*" %>

<%@page pageEncoding="UTF-8"%>
<%@page contentType="text/html;charset=UTF-8"%>

<% 
	List<NewAnswersThread> threads = (List<NewAnswersThread>) request.getAttribute("threads");
	User user = (User) request.getAttribute("user");
	Bookmarks bookmarks = user.getBookmarks();
	Principal principal = request.getUserPrincipal();
	String root = Configuration.getInstance().getRoot();
	request.setAttribute("root", root);
    request.setAttribute("activeUsers", Site.getCurrentlyActiveUsers());
	
	OrderedBy orderedBy = OrderedBy.LAST_UPDATED;
	
	if (request.getAttribute("sort") != null) {
		orderedBy = OrderedBy.ALPHABETICAL;
	}

%>


<html>
	<head>
		<meta http-equiv="Pragma" content="no-cache" />
		<meta http-equiv="expires" content="0" />
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
		<title>Site New <%= Site.getPost() %>s</title>
		<link rel="stylesheet" title="Conversation Board" type="text/css" href="<%=Configuration.getInstance().getRoot()%>/Stylesheets/<%=StyleSheets.getStyleSheetFileName(request.getCookies())%>">
		<meta name="ROBOTS" content="NOINDEX"></meta>
		
		<c:if test="${user.admin}">
			<script src="${contextPath}/Javascript/style.js" type="text/javascript"></script>
		</c:if>
		
	</head>

	<body>
	
		<%= MainMenu.display(principal) %>

		<% if (SiteMessage.getMessage() != null) { %>	
		<div class='sitemessage'><%= SiteMessage.getMessage() %></div>
		<% } %>
		<% if (BatchMessage.getMessage() != null) { %>	
		<div class='batchmessage'><%= BatchMessage.getMessage() %></div>
		<% } %>

		<c:if test="${user.yellowCarded}">
			<div class="yellowcard">You Have Been Yellow Carded By a Moderator: ${user.yellowCardReason}</div>
		</c:if>
	
		<%= BookmarksDisplay.display(bookmarks, false) %>
	
		<div class="headingblock">
			<h1>Site New <%= Site.getPost() %>s</h1>
		</div>

		<div class="optionsblock">

			<span class="leftmenulink"><a href="${root}/CustomiseSiteNewPostsControllerServlet">Customise View</a></span>

			<!-- 
			<c:choose>
				<c:when test="${requestScope.sort}">
					<span class="leftmenulink"><a href="<%=Configuration.getInstance().getRoot()%>/SiteNewAnswersControllerServlet">View By Most Recently Updated</a></span>
				</c:when>
				<c:otherwise>
					<span class="leftmenulink"><a href="<%=Configuration.getInstance().getRoot()%>/SiteNewAnswersControllerServlet?sort=true">View In Alphabetical Order</a></span>
				</c:otherwise>
			</c:choose>
			-->
			
			<span class="leftmenulink">${activeUsers} Active Users</span>

		</div>

		<div class="mainblock">
			<%=	ThreadListDisplay.display(null, threads, user.getLoginId(), orderedBy) %>
		</div>
		
		<!--<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>-->
		<!--<script type="text/javascript">_uacct = "UA-1148679-1";urchinTracker();</script>--> 
		
	</body>
	
</html>
